#pragma once

#include <vector>

#include "iprint.h"
#include "opencv2/opencv.hpp"


typedef std::pair<cv::Mat, CornerInfoV> CVImageInfo;
class DVPSPrintMessageHandler;

class DCMPrint :
    public IDCMPrint
{
public:
    DCMPrint(
        const std::string&                          aFont
    );

    ~DCMPrint();

public:
    bool
    InitNetwork(
        const ServerInfo&                           aServer
    ) override;

    bool
    GetPrinterInfo(
        PrinterModule&                              aPrinter
    ) override;

    bool
    CreateFilmSessionBox(
        const FilmSessionBoxModule&                 aFilmSessionBox
    ) override;

    bool
    CreateFilmBox(
        const FilmBoxModule&                        aFilmBox,
        bool                                        aSupportAnnotation,
        bool                                        aSupportPresentationLUT
    ) override;

    bool
    CreatePresentationLUT(
        const PresentationLUTModule&                aLut,
        unsigned long                               aCount
    ) override;

    bool
    SetImageBox(
        const ImageBoxModule&                      aImageBox,
        int                                        aFilmBoxNumber
    ) override;

    bool
    SetAnnotationBox(
        const AnnotationBoxModule&                 aAnnotationBox
    ) override;

    bool
    GetPrinterConfiguration(
        PrinterConfigurationModule&                aPrinterConfiguration
    ) override;

    bool
    GetPrintJob(
        PrintJobModule&                            aPrintJob
    ) override;

    bool
    PrintFilmSessionBox()
    override;

    bool
    PrintFilmBox(
        int                                        aFilmBoxNumber
    ) override;

    bool
    DeleteAllBox()
    override;

    bool
    ReleaseNetwork()
    override;

    bool
    CreateOpenCVImage(
        const ImageParameter&                      aImageParam,
        const CornerInfoV&                         aCorner
    ) override;

    bool
    SplicingOpenCVImage(
        const HeaderInfo&                          aHeader,
        const CVType                               aImageType,
        const std::string&                         aPath
    ) override;

private:
    //aTime: The font zoom factor
    bool
    AddCornerInfo(
        const cv::Mat&                             aMat,
        const CornerInfoV&                         aCorner,
        int                                        aTime
    );

private:
    std::shared_ptr<DVPSPrintMessageHandler>    myMessageHandler;
    std::string                                 myFilmSessionBoxUid;
    std::map<int, std::vector<std::string>>     myFilmBoxUid;
    std::vector<std::string>                    myAnnotationBoxUid;
    std::string                                 myPresentationLUTUid;
    std::vector<CVImageInfo>                    myOpencvImage;
    std::string                                 myFont;
};
